#include <mockcpp/mockcpp.hpp>
#include <testngpp/testngpp.hpp>
#include <Quantity.h>
#include <Volume.h>
#include <VolumeUnit.h>
#include <VolumeFormatter.h>
#include <sstream>

USING_MOCKCPP_NS
USING_TESTNGPP_NS

FIXTURE(VolumeEqual)
{
    TEST(4 OZ should equal to 4 OZ)
    {
        ASSERT_TRUE(Volume(4, OZ) == Volume(4, OZ));
    }

    TEST(1 OZ should equal to 2 TBSP)
    {
        ASSERT_TRUE(Volume(1, OZ) == Volume(2, TBSP));
    }

    TEST(2 TBSP should equal to 6 TSP)
    {
        ASSERT_TRUE(Volume(2, TBSP) == Volume(6, TSP));
    }

};

FIXTURE(VolumeNotEqual)
{
    TEST(6 TBSP should not equal to 5 TBSP)
    {
        ASSERT_TRUE(Volume(6, TBSP) != Volume(5, TBSP));
    }

    TEST(5 TSP should not equal to 1 TBSP)
    {
        ASSERT_TRUE(Volume(5, TSP) != Volume(1, TBSP));
    }

    TEST(2 OZ should not equal to 5 TBSP)
    {
        ASSERT_TRUE(Volume(2, OZ) != Volume(5, TBSP));
    }

    TEST(1 OZ should not equal to 10 TSP)
    {
        ASSERT_TRUE(Volume(1, OZ) != Volume(10, TSP));
    }

};

FIXTURE(VolumePlus)
{    
    TEST(20 TSP + 30 TSP should equal to 50 TSP)
    {
        ASSERT_TRUE(Volume(50, TSP) == (Volume(20, TSP)+Volume(30, TSP)));
    }

    TEST(1 OZ + 3 TSP should equal to 9 TSP)
    {
        ASSERT_TRUE(Volume(9, TSP) == (Volume(1, OZ)+Volume(3, TSP)));
    }

    TEST(1 TBSP + 3 TSP feet should equal to 6 TSP)
    {
        ASSERT_TRUE(Volume(6, TSP) == (Volume(1, TBSP)+Volume(3, TSP)));
    }

    TEST(3 OZ + 10 TBSP should equal to 16 TBSP)
    {
        ASSERT_TRUE(Volume(16, TBSP) == (Volume(3, OZ)+Volume(10, TBSP)));
    }

};

FIXTURE(VolumePrintInFormat1)
{
    std::ostringstream os;
    TEST(The output format of Volume(7, TSP) should be: 1 OZ 1 TSP)
    {
        os<<VolumeFormatter(Volume(7, TSP), FormatInUnitOrder);
        ASSERT_EQ(std::string("1 OZ 1 TSP "), os.str());
    }
    
    TEST(The output format of Volume(10, TSP) should be: 1 OZ 1 TBSP 1 TSP)
    {
        os<<VolumeFormatter(Volume(10, TSP), FormatInUnitOrder);
        ASSERT_EQ(std::string("1 OZ 1 TBSP 1 TSP "), os.str());
    }

    TEST(The output format of Volume(3, TBSP) should be: 1 OZ 1 TBSP)
    {
        os<<VolumeFormatter(Volume(3, TBSP), FormatInUnitOrder);
        ASSERT_EQ(std::string("1 OZ 1 TBSP "), os.str());
    }
    
    TEST(The output format of Volume(0, OZ) should be: 0 OZ)
    {
        os<<VolumeFormatter(Volume(0, OZ), FormatInUnitOrder);
        ASSERT_EQ(std::string("0 OZ "), os.str());
    }
};

FIXTURE(VolumePrintInFormat2)
{
    std::ostringstream os;
    TEST(The output format of Volume(1, OZ) should be: 6 TSP)
    {
        os<<VolumeFormatter(Volume(1, OZ), FormatInBaseUnit);
        ASSERT_EQ(std::string("6 TSP"), os.str());
    }

    TEST(The output format of Volume(1, TBSP) should be: 3 TSP)
    {
        os<<VolumeFormatter(Volume(1, TBSP), FormatInBaseUnit);
        ASSERT_EQ(std::string("3 TSP"), os.str());
    }
};

